﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace SD.Database
{
    public static class TimeHelper
    {
        public static DataSet ChangeTime(DataSet ds, int pId)
        {
            int timeOffset = UserFunctions.GetPlayerInt(pId, "TimeZone");
            if (ds.Tables.Count > 0)
            {
                List<string> names = new List<string>();
                foreach (DataColumn c in ds.Tables[0].Columns)
                    if (c.DataType == typeof(DateTime))
                        names.Add(c.ColumnName);

                foreach (DataRow r in ds.Tables[0].Rows)
                {
                    foreach (string name in names)
                    {
                        DateTime t =(DateTime) r[name];
                        r[name] =t.AddHours(timeOffset);
                    }
                }
            }
            return ds;
        }
    }
}
